package com.linkhub.oms.admin.modules.pickuporder.domain.vo;

import cn.hutool.core.date.DatePattern;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.linkhub.oms.common.util.QtStreamUtil;
import com.linkhub.oms.entity.PickUpGoodsOrderEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @Description: PickUpOrderQueryVO
 * @Author: echo
 * @Date: 2024/5/2 09:42
 * @Version: 1.0
 */
@Data
@ApiModel(value = "PickUpOrderVO")
public class PickUpOrderVO implements Serializable {

    @ApiModelProperty(value = "入库单号（提货id）")
    private String sysEntryOrderCode;

    @ApiModelProperty(value = "提货商品")
    private List<EntryOrderLineVO> orderLines;

    @ApiModelProperty(value = "用户id")
    private String userId;

    @ApiModelProperty(value = "商家名称")
    private String merchantUserName;

    @ApiModelProperty(value = "预计提货时间")
    @JsonFormat(pattern = DatePattern.NORM_DATE_PATTERN)
    private LocalDateTime predictDeliveryTime;

    @ApiModelProperty(value = "仓库入库时间")
    @JsonFormat(pattern = DatePattern.NORM_DATE_PATTERN)
    private LocalDateTime storageTime;

    @ApiModelProperty(value = "申请时间")
    @JsonFormat(pattern = DatePattern.NORM_DATE_PATTERN)
    private LocalDateTime createdTime;

    @ApiModelProperty(value = "提货费")
    private String takeDeliveryCost;

    @ApiModelProperty(value = "提货状态：1-待审核；2-生产中；3-运输中；4-入库中；5-已入库（已上架）；6-已取消;7-已完成")
    private Integer state;

    public static PickUpOrderVO convert(PickUpGoodsOrderEntity pickUpGoodsOrder) {
        PickUpOrderVO vo = new PickUpOrderVO();
        vo.setSysEntryOrderCode(pickUpGoodsOrder.getSysEntryOrderCode());
        vo.setOrderLines(QtStreamUtil.map(pickUpGoodsOrder.getOrderLines(), EntryOrderLineVO::convert));
        vo.setUserId(pickUpGoodsOrder.getUserId());
        vo.setMerchantUserName(pickUpGoodsOrder.getMerchantUserName());
        vo.setPredictDeliveryTime(pickUpGoodsOrder.getPredictDeliveryTime());
        vo.setStorageTime(pickUpGoodsOrder.getStorageTime());
        vo.setTakeDeliveryCost(pickUpGoodsOrder.getTakeDeliveryCost());
        vo.setState(pickUpGoodsOrder.getState().getCode());
        vo.setCreatedTime(pickUpGoodsOrder.getCreatedTime());

        return vo;


    }

}
